﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Project_1_refactored_
{
    class characteristics
    {
        #region declarations
        public string NAME { get; set; }
        public int LEVEL { get; set; }
        public int RANGE_ATTACK { get; set; }
        public int MELEE_ATTACK { get; set; }
        public int DEFENCE { get; set; }
        public int HP { get; set; }
        public int TOTAL_HP { get; set; }
        #endregion

        #region HP_MINI_BAR IMPLEMENTATION BEGIN
        protected Texture2D HP_MINI_BAR;
        protected Texture2D HP_MINI_BAR_FULL;
        protected Vector2 HP_MINI_BAR_LOCATION = Vector2.Zero;

        protected SpriteFont HP_TEXT;
        protected Vector2 HP_TEXT_LOCATION = Vector2.Zero;

        protected string HP_MINI_BAR_ASSET = @"Character\HP_MINI_BAR";
        protected string HP_MINI_BAR_FULL_ASSET = @"Character\HP_MINI_BAR_FULL";
        protected string HP_TEXT_ASSET = @"Pericles8";
        //HP_MINI_BAR IMPLEMENTATION END
        #endregion

        #region initializations
        public void newPlayer(string name)
        {
            NAME = name;
            LEVEL = 1;
            RANGE_ATTACK = 10;
            MELEE_ATTACK = 10;
            DEFENCE = 0;
            HP = 50;
            TOTAL_HP = 100;
        }

        public void newZombie()
        {
            NAME = "UNKNOWN";
            LEVEL = 1;
            RANGE_ATTACK = 10;
            MELEE_ATTACK = 5;
            DEFENCE = 0;
            HP = 10;
            TOTAL_HP = 100;
        }
        #endregion

        #region helper methods
        public string getHPinfo()
        {
            string info = string.Format("{{0} / {1}", HP, TOTAL_HP);
            return info;
        }
        #endregion

        #region common Load, Update, Draw for Player and Enemy HP MINI BAR
        #region Load
        protected void LoadHPContent(ContentManager Content)
        {
            //HP_MINI_BAR IMPLEMENTATION BEGIN
            HP_MINI_BAR = Content.Load<Texture2D>(HP_MINI_BAR_ASSET);
            HP_MINI_BAR_FULL = Content.Load<Texture2D>(HP_MINI_BAR_FULL_ASSET);
            HP_TEXT = Content.Load<SpriteFont>(HP_TEXT_ASSET);
            //HP_MINI_BAR IMPLEMENTATION END
        }
        #endregion

        #region HP bar and HP text update
        protected void HPInfoUpdate(Vector2 v2Position)
        {
            HP_MINI_BAR_LOCATION = new Vector2(v2Position.X, v2Position.Y - HP_MINI_BAR.Height);
            HP_TEXT_LOCATION = new Vector2(HP_MINI_BAR_LOCATION.X + 3, HP_MINI_BAR_LOCATION.Y - 15);
        }
        #endregion

        #region DRAW HP BAR WITH TEXT
        protected void DrawHPandTEXT(SpriteBatch spriteBatch)
        {
            string txt = string.Format("{0} / {1}", HP, TOTAL_HP);
            spriteBatch.Draw(HP_MINI_BAR_FULL, 
                HP_MINI_BAR_LOCATION,
                new Rectangle((int)HP_MINI_BAR_LOCATION.X, (int)HP_MINI_BAR_LOCATION.Y, DrawHPandTEXTHelper(), HP_MINI_BAR.Height), 
                Color.White);
            spriteBatch.Draw(HP_MINI_BAR, HP_MINI_BAR_LOCATION, Color.Black);
            spriteBatch.DrawString(HP_TEXT, txt, HP_TEXT_LOCATION, Color.Black);
        }
        #endregion

        private int DrawHPandTEXTHelper()
        {
            return HP; // WILL NEED TO BE CHANGED AND CALCULATE THE PERCENT OF HOW MUCH SHOULD BE SHOWED
        }
        #endregion
    }
}
